package site.yunnong.atvris.admin.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import site.yunnong.common.entity.VideoCommentEntity;
import site.yunnong.common.service.VideoCommentService;
import site.yunnong.common.utils.PageUtils;
import site.yunnong.common.utils.R;

import java.util.Arrays;
import java.util.Map;


/**
 * 视频评论
 *
 * @author zhangjinghao
 * @email jhzhang9102@163.com
 * @date 2021-07-09 23:45:37
 */
@RestController
@RequestMapping("common/videocomment")
public class VideoCommentController {
    @Autowired
    private VideoCommentService videoCommentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("common:videocomment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = videoCommentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("common:videocomment:info")
    public R info(@PathVariable("id") Long id){
		VideoCommentEntity videoComment = videoCommentService.getById(id);

        return R.ok().put("videoComment", videoComment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("common:videocomment:save")
    public R save(@RequestBody VideoCommentEntity videoComment){
		videoCommentService.save(videoComment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("common:videocomment:update")
    public R update(@RequestBody VideoCommentEntity videoComment){
		videoCommentService.updateById(videoComment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("common:videocomment:delete")
    public R delete(@RequestBody Long[] ids){
		videoCommentService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
